package com.aptech.childcare.components;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


//import com.aptech.student.entities.History;
//import java.io.FileInputStream;
//import java.io.IOException;
//import java.io.InputStream;
//import java.net.URL;
//import java.util.ArrayList;
//import java.util.HashMap;
//import javax.swing.JPanel;
//import net.sf.jasperreports.engine.JasperFillManager;
//import net.sf.jasperreports.engine.JasperPrint;
//import net.sf.jasperreports.engine.data.JRMapCollectionDataSource;
//import net.sf.jasperreports.view.JRViewer;


public class ReportManager {

//    @SuppressWarnings(value = "unchecked")
//    public JPanel getEnumerationViewer(String reportTitle, ArrayList<History> arrHistoryName,
//            boolean isEnumeration) {
//        JPanel viewer = null;
//        try {
//            HashMap parameterMap = new HashMap();
//            if (reportTitle.equals("")) {
//                parameterMap.put("TITLE", isEnumeration ? "THỐNG KÊ THỜI KÌ LỊCH SỬ" : "tim kiem thoi ki lich su");
//            } else {
//                parameterMap.put("TITLE", reportTitle);
//            }
//            parameterMap.put("TEN_THOI_KI", "Tên thời kì lịch sử");
//            parameterMap.put("TEN_VIET_TAT", "Tên viết tắt");
//            parameterMap.put("MO_TA", "Mô tả");
//            parameterMap.put("SO_LUONG", 23);
//
//            ArrayList reportRows = new ArrayList();
//            HashMap rowMap = null;
//            for (int i = 0; i < arrHistoryName.size(); i++) {
//                rowMap = new HashMap();
//                rowMap.put("TEN_THOI_KI", arrHistoryName.get(i).getFullName());
//                rowMap.put("MA_THOI_KI", arrHistoryName.get(i).getShortname());
//                rowMap.put("MO_TA", arrHistoryName.get(i).getComment());
//
//                reportRows.add(rowMap);
//            }
//            rowMap = new HashMap();
//            parameterMap.put("SO_LUONG", new Integer(reportRows.size()));
//
//            JasperPrint jasperPrint = JasperFillManager.fillReport(new FileInputStream("thongketheothoiki.jasper"),
//                    parameterMap,
//                    new JRMapCollectionDataSource(reportRows));
//
//            viewer = new JRViewer(jasperPrint);
//        } catch (Exception ex) {
//            System.out.println("Error!");
//        }
//
//        return viewer;
//    }
//
//    private InputStream getInputStream(String reportName) {
//        URL url = getClass().getResource("../ui/jasper/" + reportName);
//        InputStream input = null;
//
//        try {
//            input = url.openStream();
//            return input;
//        } catch (IOException ex) {
//            return null;
//        }
//    }
}
